<template>
  <view class="my-cms">
	  <!-- 公共组件-每个页面必须引入 -->
	  <public-module></public-module>
    <view class="num">
      <text>合计<text class="num-color">{{people}}</text>人，</text>
      <text> 销售量：<text class="num-color">{{weight}}</text>吨，</text>
      <text>预计分成<text class="num-color">{{money}}</text>元</text>
    </view>
    <u-index-list :index-list="indexList" v-if="people > 0">
      <template v-for="(item, index) in itemArr">
        <u-index-item>
          <u-index-anchor :text="indexList[index]" bgColor="none"></u-index-anchor>
		  <div style="background: rgba(255,255,255,1);box-shadow: 0px 0px 10px rgba(0,17,52,0.09);border-radius: 18rpx;overflow: hidden;">
			<view class="cms-bottom" v-for="(el,index1) in item" :key="index1" @click="toCustom(el)">
			  <view class="img"><u-avatar :src="el.userHeader"></u-avatar></view>
			  <view class="adr-info">
			    <view class="adr-top"><text class="name">{{el.contactPerson}}</text><text
			        class="phone">{{el.storePhone}}</text></view>
			    <view class="adr-bottom">
			      <text>{{el.createdAt}}</text><text>加入&nbsp;&nbsp;&nbsp;累计销售量{{el.tonnage}}吨</text>
			    </view>
			  </view>
			</view>
		  </div>
          
          <!--   <view class="list-cell" v-for="(cell, index) in item">
            {{cell}}
          </view> -->
        </u-index-item>
      </template>
    </u-index-list>
	<div v-else style="margin-top:200rpx;">
		<u-empty text="暂无数据" mode="list"  icon="https://pic.moresu.com/Fs-rZPgApAIGT8szof2GUATIiF8N" ></u-empty>
	</div>
	
  </view>
</template>

<script>
  import {
    supplierList
  } from '@/config/api2.js'
  export default {
    data() {
      return {
        people: 1,
        weight: 100,
        money: 10000,
        indexList: [],
        itemArr: [],
      }
    },
    onShow() {
      this.getSupplierList()
    },
    methods: {
      toCustom(item) {
        uni.navigateTo({
          url: 'supplierInfo?supplierId=' + item.supplierId
        })
      },
      getSupplierList() {
        supplierList().then(res1 => {
		  this.people = res1.count;
		  this.weight = res1.totalTonnage;
		  this.money = res1.totalCommission;
		  this.indexList = [];
		  this.itemArr = [];
          this.indexList = res1.pinyin
          res1.pinyin.forEach(item => {
            const arr = []
            res1.list.forEach(item1 => {
              if (item1.pinyinLetter == item) {
                arr.push(item1)
              }
            })
            this.itemArr.push(arr)
          })
		 if(res1.listTop.length > 0){
			  this.indexList.unshift('⭐')
			  this.itemArr.unshift(res1.listTop)
		 }
        })
		
      },
    }
  }
</script>

<style lang="scss">
  @import '@/style/wmj.scss';
  .my-cms{
  	  padding:24rpx 32rpx;
  	  .cms-bottom{
  		  border-bottom:1px solid #eee;;
  	  }
  	   .cms-bottom:last-child{
  		   border-bottom: 0;
  	   }
  	   .u-index-anchor{
  		   border-width: 0 !important;
  	   }
  }
</style>